import axios from 'axios';
// 创建实例
const Instance = axios.create({
  baseURL: 'https://rest.nexmo.com/',
  timeout: 1000 * 60,
  withCredentials: 'true' // 允许浏览器接受跨域请求返回的set-cookie头
});

// request统一处理操作
Instance.interceptors.request.use(config => {
  return config;
}, (error) => {
  return Promise.reject(error);
});

// response统一处理操作
Instance.interceptors.response.use(res => {
  return res.data;
}, (error) => {
  var errorDada =  ''
  if (error && error.response && error.response.data) {
    errorDada =error.response.data
  }
  return Promise.reject(errorDada);
});

export default Instance;
